---

- name: NEXUS | Removing previously Groovy script {{ item }}
  uri:
    url: "http://{{ nexus_host }}:{{ nexus_port }}{{ nexus_context_path }}service/rest/v1/script/{{ item | regex_replace('/', '_') }}"
    user: admin
    password: "{{ current_nexus_admin_password }}"
    method: DELETE
    force_basic_auth: yes
    status_code: 204,404

- name: NEXUS | Declaring Groovy script {{ item }}
  uri:
    url: "http://{{ nexus_host }}:{{ nexus_port }}{{ nexus_context_path }}service/rest/v1/script"
    user: admin
    password: "{{ current_nexus_admin_password }}"
    body_format: json
    method: POST
    force_basic_auth: yes
    status_code: 204
    body:
      name: "{{ item | regex_replace('/', '_') }}"
      type: groovy
      content: "{{ lookup('file', 'scripts/' + item + '.groovy') }}"
